package com.sdutcm.xuake.xuanke_demo.service;

import com.sdutcm.xuake.xuanke_demo.bean.User;
import com.sdutcm.xuake.xuanke_demo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-09-07 20:34
 * @package com.sdutcm.xuankePoint.service
 * @description
 */
@Service
public class UserService {
    @Autowired
    UserDao userDao;


    //登陆
    public boolean login(int id, String password) {
        Optional<User> byId = userDao.findById(id);
        User user = byId.get();
        return user.getPassword().equals(password)?true:false;

    }


    //修改密码
    public boolean updatePassword(int xuehao,String password ) {
        User user=new User();
        user.setId(xuehao);
        user.setPassword(password);
        return userDao.save(user)!=null?true:false;
    }

}
